package com.qxglxt.qxglxt.dao;

import java.util.List;

import javax.transaction.Transactional;

import com.qxglxt.qxglxt.model.Roles;

import com.qxglxt.qxglxt.model.Users;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import org.springframework.data.jpa.repository.Modifying;

import org.springframework.data.jpa.repository.Query;

public interface IUserRolesDao extends JpaRepository<UserRoles, Integer> {

    // 修改角色

    @Transactional

    @Modifying

    @Query("update Roles r set r.name=:name where r.id=:id")

    int editRole(String id, String name);

    // 删除角色

    @Transactional

    @Modifying

    @Query("delete Roles r  where r.id=:id")

    int delRole(String id);

    // 获取指定用户的角色

    @Query("select u from Roles u where u.id = :id")

    List<Roles> getRoles(String id);

}